home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Misc / InstallerNG / developer / gui / example / igui_CopylibConfirm.c < prev    next >
C/C++ Source or Header  |  2000-01-01  |  4KB  |  163 lines

  1.  
  2. #include "includes.h"
  3. #include "installergui_data.h"
  4.  
  5. /********************************************************************
  6.  *
  7.  *  DESCRIPTION
  8.  *
  9.  *  you all know the panl which pops up, when the installer
  10.  *  is up to copy files with respect to their versions. well, 
  11.  *  here it is...  the source and destination file data are
  12.  *  described by special iguicl_FileSpec structures, which
  13.  *  are given by the installer itself. you simply build the
  14.  *  strings to be shown from the (localized?) patterns and 
  15.  *  wait for users response. thats it :=)
  16.  *
  17.  *  IN:  application - pointer to the private application structure
  18.  *       localenv - the local environment of the related COPYLIB function
  19.  *       src
  20.  *       dest - iguicl_FileSpec of the source and destination file
  21.  *
  22.  *  OUT: 1 - if the user choses "Proceed"
  23.  *       0 - if the user choses "Skip"
  24.  *
  25.  */
  26.  
  27. /********************************************************************
  28.  *
  29.  *  STATIC
  30.  *
  31.  */
  32.  
  33. /********************************************************************
  34.  *
  35.  *  EXTERN
  36.  *
  37.  */
  38.  
  39. /********************************************************************
  40.  *
  41.  *  PUBLIC
  42.  *
  43.  */
  44.  
  45. /********************************************************************
  46.  *
  47.  *  CODE
  48.  *
  49.  */
  50.  
  51. long __asm igui_CopylibConfirm(register __a0 APTR application,
  52.                                register __a1 struct FunctionEnvironment *localenv,
  53.                                register __a2 struct iguicl_FileSpec *src,
  54.                                register __a3 struct iguicl_FileSpec *dest)
  55. {
  56.   #ifdef DEBUG
  57.   DEBUG_MAKRO
  58.   #endif
  59.  
  60.   {
  61.     struct Application *app = (struct Application *) application;
  62.  
  63.     char *body;
  64.  
  65.     APTR obj;
  66.  
  67.     long retval = 1,
  68.          event,
  69.          args[7];
  70.  
  71.     // create an arg-array for the StringF function
  72.     args[0] = (long) src->ifs_FileName;
  73.     args[1] = src->ifs_Version;
  74.     args[2] = src->ifs_Revision;
  75.     args[3] = src->ifs_FileSize;
  76.     args[4] = (long) src->ifs_DateString;
  77.     
  78.     args[6] = localenv->fe_Dest;
  79.  
  80.     // if the destination file exists, use its data!
  81.     if (dest->ifs_Exists)
  82.     {
  83.       char *body2;
  84.       long args2[4];
  85.  
  86.       args[5] = (long) app->app_Texts[COPYLIB_VERSION];
  87.  
  88.       args2[0] = dest->ifs_Version;
  89.       args2[1] = dest->ifs_Revision;
  90.       args2[2] = dest->ifs_FileSize;
  91.       args2[3] = (long) dest->ifs_DateString;
  92.  
  93.       body2 = sav_StringF2(app->app_Texts[COPYLIB_PATTERN], &args);
  94.       if (!body2) { /* OUT OF MEMORY */ return(0); }
  95.  
  96.       body = sav_StringF2(body2, &args2);
  97.       sav_FreeVec(body2);
  98.     }
  99.  
  100.     // no destination file!
  101.     else
  102.     {
  103.       args[5] = (long) app->app_Texts[COPYLIB_NOVERSION];
  104.       body = sav_StringF2(app->app_Texts[COPYLIB_PATTERN], &args);
  105.     }
  106.  
  107.     // there was not enough free memory, to create the formatted text
  108.     if (!body) { /* OUT OF MEMORY */ return(0); }
  109.     else
  110.     {
  111.       // after we created the text, we can now create the object itself
  112.       obj = GroupObject,
  113.                    Child, HVSpace,
  114.                    Child, TextObject,
  115.                      MUIA_Frame, MUIV_Frame_None,
  116.                      MUIA_Text_Contents, localenv->fe_Prompt,
  117.                      MUIA_Text_SetMin, TRUE,
  118.                      MUIA_Text_PreParse, "\33c",
  119.                    End,
  120.                    Child, TextObject,
  121.                      MUIA_Background, MUII_TextBack,
  122.                      //MUIA_Frame, MUIV_Frame_Text,
  123.                      MUIA_Text_Contents, body,
  124.                      MUIA_Text_SetMin, TRUE,
  125.                      MUIA_Text_PreParse, "\33c",
  126.                    End,
  127.                    Child, HVSpace,
  128.                  End;
  129.  
  130.       // set the help text for this function
  131.       igui_SetHelp(app, (char *) localenv->fe_Help);
  132.  
  133.       //
  134.       if (guistuff_NewContent(app, obj))
  135.       {
  136.         // make the "cancel" button into a "skip this part" button
  137.         igui_NameCancel(app, app->app_Texts[BUTTON_SKIP]);
  138.  
  139.         // wait, until the user "proceeds", "skips" or confirms the "quit" action
  140.         do
  141.         {
  142.           event = igui_QuietWaitApp(app);
  143.  
  144.           if      (event == GUIEVENT_PROCEED) { retval = 1; break; }
  145.           else if (event == GUIEVENT_ABORT)   { retval = 0; break; }
  146.         }
  147.         while (guistuff_HandleGUIEvent(app, event));
  148.  
  149.         // restore the "cancel" button
  150.         igui_NameCancel(app, app->app_Texts[BUTTON_CANCEL]);
  151.       }
  152.  
  153.       // free the memory of the body-text
  154.       sav_FreeVec(body);
  155.     }
  156.  
  157.     //
  158.     igui_EmptyPanel(app);
  159.     return(retval);
  160.   }
  161. }
  162.  
  163.